import request from '@/utils/request'
import R from '@/types/conduit/R'
import ShopActivityInstance from '@/types/entity/ShopActivityInstance'
import { FullReductionActivityDTO, NewCustomerActivityDTO, ReduceDeliveryFreeActivityDTO } from '@/types/param/activity'

export const listShopActivityInstanceTypeList = (activityTypeId: number | string): Promise<R<ShopActivityInstance[]>> =>
  request({
    url: `/shop/shop-activity-instance/${activityTypeId}`,
    method: 'GET'
  })

export const putFullReductionActivity = (fullReductionActivityDTO: FullReductionActivityDTO): Promise<R<null>> =>
  request({
    url: `/shop/shop-activity-instance/full-reduction-activity`,
    method: 'PUT',
    data: fullReductionActivityDTO
  })
export const deleteShopActivityInstance = (activityInstanceId: number): Promise<R<null>> =>
  request({
    url: `/shop/shop-activity-instance/activity/${activityInstanceId}`,
    method: 'DELETE'
  })

export const getShopActivityInstance = (activityInstanceId: number): Promise<R<ShopActivityInstance>> =>
  request({
    url: `/shop/shop-activity-instance/activity/${activityInstanceId}`,
    method: 'GET'
  })

export const putNewCustomerActivity = (newCustomerActivityDTO: NewCustomerActivityDTO): Promise<R<null>> =>
  request({
    url: `/shop/shop-activity-instance/new-customers-activity`,
    method: 'PUT',
    data: newCustomerActivityDTO
  })
export const putReduceDeliveryFreeActivity = (reduceDeliveryFreeActivityDTO: ReduceDeliveryFreeActivityDTO): Promise<R<null>> =>
  request({
    url: `/shop/shop-activity-instance/reduce-delivery-free-activity`,
    method: 'PUT',
    data: reduceDeliveryFreeActivityDTO
  })

export const participateOrExitDivineVoucher = (state: number): Promise<R<null>> =>
  request({
    url: `/shop/shop-activity-instance/divine-voucher/${state}`,
    method: 'PUT'
  })
